<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-6">
        <h2>商品管理</h2>
        <ol class="breadcrumb">
            <li class="active">
                 <strong><a href="index.html">主页</a></strong>
            </li>
            <li>
                <a>商品管理</a>
            </li>
        </ol>
    </div>
    <div class="col-lg-6">
        <h2><a href="{:U('admin/prodect/add')}" class="btn btn-success btn-lg pull-right">添加商品</a></h2>
    </div>
</div>
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
         <div class="ibox-content">
                <table class="table  table-hover">
                    <thead>
                    <tr>
                        <th></th>
                        <th>id</th>
                        <th>商品名称</th>
                        <th>分类</th>
                        <th>价格</th>
                        <th>状态</th>
                        <th>库存</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <volist name="prodects" id="vo" >
                        <tr>
                            <td ><input type="checkbox" value="{$vo.id}" class='is_select'></td>
                             <td>{$vo.id}</td>
                            <td><img style="height:50px; float:left;" src="__ROOT__{$vo.img}"><h4>{$vo.title}</h4></td>
                            <td>{$vo.name}</td>
                            <td>{$vo.price}</td>
                            <td>{$vo.status|prodect_status}</td>
                            <td>{$vo.stock}</td>
                             <td><a href="{:U('admin/prodect/edit/id/'.$vo[id])}" class="btn btn-info btn-xs">编辑</a><a href="{:U('admin/prodect/del/',array('id'=>$vo[id]))}" class="btn btn-danger btn-xs del" >删除</a></td>
                        </tr>
                    </volist>
                    </tbody>
                </table>
                <div>
                    <label>
                        <input type="checkbox" id="checkall"> 全选
                    </label>
                </div>
                <div id="del_all"><a href="" class="btn btn-danger btn-xs">删除选中项</a></div>
        {$page}
        </div>
    </div>
</div>
<script type="text/javascript">
        $(window).load(function(){
            $('#checkall').click(function(){
                $('input:checkbox').prop("checked",this.checked);
            });
             $('#del_all').click(function(){
                var ids=[];
                $('.is_select').each(function(i,item){
                    if($(item).prop("checked")){
                        ids.push($(item).val());
                    }
                });
                if(ids.length==0){
                    alert("没有选择任何商品");
                }else{
                    if(confirm('是否删除？')){
                    $.post("<?php echo U('admin/prodect/del_all') ?>",{
                        "ids":ids},function(data){
                            if(data=="ok"){location.reload()}
                        })
                    }
                }
                return false;
            });
              $('.del').click(function(){
                if(confirm('是否删除？')){
                var href=$(this).attr('href');
                $.get(href,function(data,status){
                    location.reload(); 
                });
            }
                return false;
            });

        })
    </script>
    